import { API_LIST } from '../../../Api/Api'
import { commonTableList, InputModal } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'

import {
    getdOrganizationList,
    GetProfessionalMajorCategory,
    GetProfessionalCategoryNameList,
    GetProfessionalCertificateMajorNameList,
    GetProfessionalMajorCategoryNameList,
    GetProfessionalSubMajorNameList,
    GetProfessionalOriginalTitleNameList,
} from '../Common/Conversion'

export const ProfessionalQualifications = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    const certificateArr = await GetProfessionalCategoryNameList()
    const certificateMajorArr = await GetProfessionalCertificateMajorNameList()
    const cmajorCategoryNameArr = await GetProfessionalMajorCategoryNameList()
    const subMajorNameArr = await GetProfessionalSubMajorNameList()
    const originalTitleNameArr = await GetProfessionalOriginalTitleNameList()

    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'ProfessionalQualifications' },
            commonTableList.uuid,
            {
                dataIndex: 'tableName',
                title: '姓名',
                valueType: 'input',
                rules: true,
                width: 80,
            },
            {
                dataIndex: 'identityCard',
                title: '身份证号',
                valueType: 'input',
                rules: true,
                width: 160,
            },
            {
                dataIndex: 'mobilePhone',
                title: '手机号码',
                valueType: 'input',
                width: 120,
                rules: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'gender',
                title: '性别',
                valueType: 'select',
                valueEnum: { 男: '男', 女: '女' },
                width: 80,
                rules: true,
                hideInSearch: true,
            },
            {
                ...commonTableList.organizationUuid,
                valueEnum: await getdOrganizationList(2),
                width: 160,
            },
            {
                dataIndex: 'certificate',
                title: '证书名称',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
                width: 240,
                renderFormItem: () => <InputModal options={certificateArr} />,
            },
            {
                dataIndex: 'certificateMajor',
                title: '证书专业',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
                hideInTable: true,
                width: 240,
                renderFormItem: () => <InputModal options={certificateMajorArr} />,
            },
            {
                dataIndex: 'certificateName',
                title: '证书名称与专业',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                width: 240,
            },

            {
                dataIndex: 'majorCategory',
                title: '专业大类',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                hideInTable: true,
            },
            {
                dataIndex: 'subMajor',
                title: '小专业',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                hideInTable: true,
            },
            {
                dataIndex: 'originalTitle',
                title: '原职称',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                hideInTable: true,
            },
            {
                dataIndex: 'majorCategoryName',
                title: '专业大类',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                renderFormItem: () => <InputModal options={cmajorCategoryNameArr} />,
            },
            {
                dataIndex: 'subMajorName',
                title: '小专业',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                renderFormItem: () => <InputModal options={subMajorNameArr} />,
            },
            {
                dataIndex: 'originalTitleName',
                title: '原职称',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                renderFormItem: () => <InputModal options={originalTitleNameArr} />,
            },
            {
                dataIndex: 'CascaderA01',
                title: '当前专业大类/专业/职称',
                valueType: 'Cascader',
                valueEnum: await GetProfessionalMajorCategory(),
                valueList: ['majorCategory', 'subMajor', 'originalTitle'],
                hideInTable: true,
                hideInSearch: true,
                rules: true,
            },

            {
                dataIndex: 'grantTime',
                title: '授予时间',
                valueType: 'Date',
                rules: true,
                width: 160,
                hideInSearch: true,
            },
            {
                dataIndex: 'employmentYears',
                title: '受聘年限',
                valueType: 'inputNumber',
                width: 160,
                rules: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'graduationSchoolAndMajor',
                title: '毕业院校及专业',
                valueType: 'input',
                width: 160,
                rules: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'graduationTime',
                title: '毕业时间',
                valueType: 'Date',
                width: 160,
                rules: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'educationLevel',
                title: '文化程度',
                valueType: 'select',
                rules: true,
                valueEnum: { 中专: '中专', 大专: '大专', 本科: '本科', 研究生: '研究生', 博士: '博士' },
                width: 160,
            },
            {
                dataIndex: 'overlapEducation',
                title: '第一学历与最高学历之间衔接是否符合要求（学历套读）',
                valueType: 'select',
                rules: true,
                valueEnum: { 是: '是', 否: '否' },
                width: 160,
                hideInSearch: true,
            },

            {
                dataIndex: 'majorCategory1',
                title: '拟评专业大类',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                hideInTable: true,
            },
            {
                dataIndex: 'rankLevel',
                title: '拟评职称等级',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                hideInTable: true,
            },
            {
                dataIndex: 'subSpecialty',
                title: '拟评小专业',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                hideInTable: true,
            },
            {
                dataIndex: 'rankLevelName',
                title: '拟评职称',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                renderFormItem: () => <InputModal options={originalTitleNameArr} />,
            },
            {
                dataIndex: 'subSpecialtyName',
                title: '拟评小专业',
                valueType: 'input',
                width: 160,
                hideInAdded: true,
                hideInModify: true,
                renderFormItem: () => <InputModal options={subMajorNameArr} />,
            },
            {
                dataIndex: 'CascaderA02',
                title: '拟评专业大类/专业/职称',
                valueType: 'Cascader',
                valueEnum: await GetProfessionalMajorCategory(),
                valueList: ['majorCategory1', 'subSpecialty', 'rankLevel'],
                hideInTable: true,
                hideInSearch: true,
                rules: true,
            },
            {
                dataIndex: 'isQualified',
                title: '取得各阶段职称是否符合年限要求',
                valueType: 'select',
                rules: true,
                valueEnum: { 是: '是', 否: '否' },
                hideInSearch: true,
                width: 160,
            },
            {
                dataIndex: 'currentWorkAchievements',
                title: '现有工作业绩',
                valueType: 'input',
                hideInSearch: true,
                width: 160,
            },
            {
                dataIndex: 'lackOfWorkAchievements',
                title: '缺少工作业绩',
                valueType: 'input',
                hideInSearch: true,
                width: 160,
            },
            {
                dataIndex: 'promotionDifficulties',
                title: '晋升困难',
                valueType: 'input',
                hideInSearch: true,
                width: 160,
            },
            {
                dataIndex: 'companyAssistanceNeeded',
                title: '需要公司提供的帮助',
                valueType: 'input',
                hideInSearch: true,
                width: 160,
            },
            {
                dataIndex: 'remark',
                title: '备注',
                valueType: 'input',
                hideInSearch: true,
                width: 160,
            },
            { ...commonTableList.BeginDate, title: '开始授予时间', dataIndex: 'BeginDate1' },
            { ...commonTableList.EndDate, title: '结束授予时间', dataIndex: 'EndDate1' },
            { ...commonTableList.BeginDate, title: '开始受聘年限', dataIndex: 'BeginEmploymentYears' },
            { ...commonTableList.EndDate, title: '结束受聘年限', dataIndex: 'EndEmploymentYears' },
            { ...commonTableList.BeginDate, title: '开始毕业时间', dataIndex: 'BeginDate2' },
            { ...commonTableList.EndDate, title: '结束毕业时间', dataIndex: 'EndDate2' },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenTwoRouter
                            key="TwoOne"
                            title="证书管理"
                            twoTitle="证书信息详情"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'ProfessionalQualifications',
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
